Skip to content

feat(i18n): downloadable language packs - #898

Merged
LeanBitLab merged 5 commits into
mainfrom
feat/language-packs
Nov 22, 2026
Merged

LeanBitLab merged 5 commits into
mainfrom
feat/language-packs

Conversation

@LeanBitLab

@LeanBitLab LeanBitLab commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Prototype for moving the translated UI strings out of the APK (about 4.9 MB of resources.arsc) into downloadable language packs. Packs are built and published by LeanType-Language-Packs (manual workflow, run with a release tag after this is in a release).

How it works

  • A pack is a resource-only APK with one locale's strings*.xml, built by tools/build_language_pack.py for a given app APK. It reuses that APK's resource IDs (aapt2 --stable-ids from aapt2 dump resources), so no Gradle change is needed and it also works for the reproducible F-Droid APK.
  • The pack's versionName holds the CRC32 of the app's resources.arsc and its locale. The app loads a pack only when package name and checksum match the running build (betas reuse versionCodes, so versionCode is not enough).
  • A pack may only hold strings: a manifest plus a resource table with string, plurals and array resources, nothing else. Packs from an older build are deleted at startup.
  • LanguagePacks loads packs from device-protected storage (works before first unlock) with ResourcesLoader on Android 11+, into the app resources (shared by the keyboard service) and every activity.
  • New "App translation" row on Languages & Layouts (Android 11+, non-English app language): download, import from file, remove. Download URL: LeanType-Language-Packs/releases/download/<versionName>-<crc>/<locale>.apk. The offline flavor opens the releases page instead.
  • -PenglishOnly leaves values-*/strings*.xml out of the APK. Locale folders keep their typing config (bools.xml etc.). Default builds are unchanged.

Separate commits: setup_not_active_title had lost the space next to %s in 25 locales and was empty in Russian; eight locales lost formatted="false" on strings with a literal % (strict aapt2 compile failed on bn).

Tested (device, Android API 37, English-only standard debug build)

  • No pack: app shows English, row says "not installed".

  • Download: 404 handled (no release yet), message shown.

  • Import of a German pack: Settings switches to German; still German after a force-stop (pack loads at startup).

  • Remove: pack deleted, back to English.

  • Release build (R8, resource shrinking, release key), English-only: imported German pack loads, Settings and the keyboard's clipboard panel are German, the keyboard process loads the pack after a force-stop.

  • Offline flavor (debug, English-only): Download opens the releases page, import switches to German.

  • A pack with a color resource and a pack from the previous build are both rejected and deleted.

Follow-ups (separate PRs)

  • Release workflow: build English-only and run the pack workflow per release
  • All-languages APK for Android 6-10 (no ResourcesLoader)
  • Prompt to download the pack after an app update

The auto-translated setup_not_active_title had lost the space next to %s in 25 locales (e.g. "LeanType aktivieren" became "LeanTypeaktivieren") and was empty in Russian.
Translated UI strings can ship as resource-only APKs that the app loads on Android 11+ with ResourcesLoader.

- LanguagePacks loads packs from device-protected storage into the app and activity resources. A pack is used only when its package name and resources.arsc checksum match the running build.
- "App translation" row on the Languages screen: download, import from file, remove.
- tools/build_language_pack.py builds a pack for a given app APK, reusing its resource IDs.
- -PenglishOnly leaves values-*/strings*.xml out of the APK; locale folders keep their typing config.
aapt2 compile --legacy accepts the same strings as the app build (bn failed otherwise). Packs no longer carry the English defaults (--no-resource-removal keeps strings without a default), which halves their size: 7.5 MB for all 55 locales.
A pack may hold nothing but a manifest and a resource table with string, plurals and array resources, so it cannot replace layouts, drawables or other values. Packs that no longer fit the app build are deleted at startup instead of being skipped.
Eight locales lost formatted="false" on strings with a literal %, so aapt2 read them as format specifiers (strict compile failed on bn).
@LeanBitLab
LeanBitLab marked this pull request as ready for review November 22, 2026 13:29
@LeanBitLab LeanBitLab changed the title feat(i18n): prototype downloadable language packs feat(i18n): downloadable language packs Nov 22, 2026
@LeanBitLab
LeanBitLab merged commit 215d960 into main Nov 22, 2026
1 check passed
@LeanBitLab
LeanBitLab deleted the feat/language-packs branch November 22, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant